<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组合继承</title>
</head>

<body>
    <script>
        // 父类
        function Person(name, age) {
            this.name = name
            this.age = age
        }

        Person.prototype.sayhi = function() {
            console.log('aaaaa');
        }

        // 子类
        function Stundent(gender, name, age) {
            this.gender = gender;
            // 实现call继承
            Person.call(this, name, age)
        }
        // 原型链继承
        Stundent.prototype = new Person() // 可以不用传 对象访问机制 自己有 不向父类要
        Stundent.prototype.play = function() {
            console.log('bbbbbb');
        }

        const s = new Stundent('nan', 'zhangsan', 20);
        console.log(s);
    </script>
</body>

</html>